# coding: utf-8
from app import create_app, db, whooshee
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager, Server
from script.fakes import faker_user, faker_game, faker_payment
import click
from app.fakes import *
app = create_app('development')
migrate = Migrate(app, db)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
manager.add_command("runserver", Server('0.0.0.0', port=5000))

@manager.option('-u', '--user', dest='user')
# @manager.option('-p', '--post', dest='post')
# @manager.option('-c', '--comment', dest='comment')
def forge(user):
    # click.echo('Generating the %s user...' % user)
    # faker_user()
    # click.echo('Generate user over')
    # click.echo('Generating the game...')
    # faker_game()
    click.echo('Generating the payment...')
    faker_payment()
    click.echo('over')

@manager.command
def reset_index():
    click.echo('starting reset index')
    whooshee.reindex()
    click.echo('reset index over')

if __name__ == "__main__":
    manager.run()
